// Task states
#define TS_RUNNING  0
#define TS_SLEEPING 1
#define TS_FINISHED 2

struct _task_t {
  int        state;
  pthread_t  thread;
  sem_t      step_begin;
  // Tasks are doubly-linked
  task_t     next;
  task_t     prev;
  // Tasks can also be linked in the wait list of a semaphore
  task_t     next_waiter;

  sem_t msg_rec;

  sem_t msg_env;


  char* mot_env;

};

extern task_t current_task;

void task_start (task_t task);
void task_finish ();
